import request from '@/utils/request'

// 设备

/**
 * 获取列表
 *
 * @export
 * @param {*} data  { bindType, deviceCode, deviceType, fixedAssets }
 * @returns
 */
export function fetchDeviceFindPage(data) {
  return request({
    url: '/pc/base/device/findPage',
    method: 'post',
    data
  })
}

/**
 * 获取详情
 *
 * @export
 * @param {*} data { id }
 * @returns
 */
export function fetchDeviceGet(params) {
  return request({
    url: '/pc/base/device/get',
    method: 'get',
    params
  })
}

/**
 * 添加
 *
 * @export
 * @param {*} data { name, deviceCode, deviceType, bindType, assetCode, factory, modelCode, address, maintenanceMan,
 *                   maintenancePhone, originType, price, ownership, lat, lng, usages }
 * @returns
 */
export function fetchDeviceAdd(data) {
  return request({
    url: '/pc/base/device/add',
    method: 'post',
    data
  })
}

/**
 * 更新
 *
 * @export
 * @param {*} data { id, name, deviceType, bindType, assetCode, factory, modelCode, address, maintenanceMan,
 *                   maintenancePhone, originType, price, ownership, lat, lng, usages }
 * @returns
 */
export function fetchDeviceUpdate(data) {
  return request({
    url: '/pc/base/device/update',
    method: 'post',
    data
  })
}

/**
 * 删除
 *
 * @export
 * @param {*} data { id }
 * @returns
 */
export function fetchDeviceDelete(params) {
  return request({
    url: '/pc/base/device/delete',
    method: 'post',
    params
  })
}

/**
 * 导出
 *
 * @export
 * @param {*} params
 * @returns
 */
export function fetchDeviceExport(params) {
  return request({
    url: '/pc/base/device/exportDevice',
    method: 'get',
    params,
    responseType: 'blob',
    getResponse: true,
    download: true,
    onlyFile: true
  })
}
